package com.github.jspxnet.worktask.table;


import com.github.jspxnet.enums.RecycleEnumType;
import com.github.jspxnet.json.JsonIgnore;
import com.github.jspxnet.sober.annotation.Column;
import com.github.jspxnet.sober.annotation.Id;
import com.github.jspxnet.sober.annotation.Nexus;
import com.github.jspxnet.sober.annotation.Table;
import com.github.jspxnet.sober.enums.MappingType;
import com.github.jspxnet.utils.StringUtil;
import com.github.jspxnet.worktask.model.enums.FlowNodeEnumType;
import com.github.jspxnet.worktask.model.enums.JobEnumType;
import com.github.jspxnet.worktask.model.enums.WorkTaskEnumType;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 *
 * 数据时时的同步到历史记录表,当这里办理完成,这里清空,这里查询代办数据
 *
 */

@Table(name = "jwf_work_Task", caption = "当前流程节点模型",cache = false,create = true)
@Data
public class WorkTask implements Serializable {
    @Id
    @Column(caption = "ID", notNull = true)
    private long id = 0;

    @Column(caption = "流程编号", length = 32, notNull = true)
    private String flowNo = StringUtil.empty;

    @Column(caption = "文档编号", length = 100, notNull = true)
    private String documentNo = StringUtil.empty;

    @Column(caption = "命名空间", length = 50, dataType = "isLengthBetween(1,50)")
    private String namespace = StringUtil.empty;

    @Column(caption = "节点ID", length = 32, notNull = true)
    private String nodeId = StringUtil.empty;

    //flowNo+documentNo+nodeId+userId+version+年月日 生成md5, 用这个id是为了确保迁移方便,查询也方便
    @Column(caption = "用户流程ID", length = 32, notNull = true)
    private String userFlowId = StringUtil.empty;

    @Nexus(mapping = MappingType.OneToMany, field = "userFlowId", targetField = "userFlowId",targetEntity = UserFlowLog.class,delete = true)
    private List<UserFlowLog> userFlowLogList = new ArrayList<>(0);

    @Column(caption = "用户id列表", length = 10000)
    private String users = StringUtil.empty;

    //驳回重置的时候+1,放入历史
    @Column(caption = "文档编号", notNull = true)
    private int version = 0;

    @Column(caption = "创建时间", notNull = true)
    protected Date createDate = new Date();

    //这里结束了,并不一定是真的完成了,比如签收 已经抄送出去了. 但是是否签收了,需要
    @Column(caption = "节点类型", length = 2,enumType = FlowNodeEnumType.class , notNull = true,input = "select")
    private int flowNodeType = FlowNodeEnumType.TASK.getValue();

    @Column(caption = "条件类型", length = 2,enumType = JobEnumType.class , notNull = true)
    private int jobType = JobEnumType.NONE.getValue();

    @Column(caption = "任务类型", length = 2,enumType = WorkTaskEnumType.class , notNull = true)
    private int workTaskType = WorkTaskEnumType.NONE.getValue();

    @JsonIgnore
    @Column(caption = "节点被回退", length = 2, enumType = RecycleEnumType.class,  notNull = true)
    private int recycleType = RecycleEnumType.NO_RECYCLE.getValue();

    @JsonIgnore
    @Column(caption = "回退时间", notNull = true)
    private Date recycleDate = new Date();


}
